package com.atguigu.controller;

import com.atguigu.entity.UserInfo;
import com.atguigu.result.RetVal;
import com.atguigu.result.RetValCodeEnum;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * UserController
 *
 * @author yangchao
 * @version 开发阶段
 * @description TODO
 * @date 2022/1/8 21:00
 */
@RestController
@RequestMapping("/product")
public class UserController {
    /**
     *   用户登录验证
     */
    @PostMapping("/user/userLogin")
    public RetVal list(@RequestBody UserInfo userInfo) {
        if (userInfo.getLoginName().equals("admin") ){
            if (userInfo.getPasswd().length() < 7) {
                return RetVal.ok(userInfo.getName());
            }
        }
        return RetVal.fail().code(RetValCodeEnum.LOGIN_FAILED.getCode()).message(RetValCodeEnum.LOGIN_FAILED.getMessage());
    }

}
